<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>
    PIL jpeg decoder not available when starting script from bash console : Forums : PythonAnywhere
</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="Forums : PythonAnywhere">
        <meta name="author" content="PythonAnywhere LLP">
        <meta name="google-site-verification" content="O4UxDrfcHjC44jybs2vajc1GgRkTKCTRgVzeV6I9V14" />

        <!-- Le styles -->
        <link href="/static/bootstrap/css/bootstrap.css" rel="stylesheet">
        <link href="/static/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
        <link href="/static/anywhere/styles/bootstrap_base.css" rel="stylesheet">
        
    
    <link rel="stylesheet" href="/static/anywhere/styles/forums.css" type="text/css" media="screen" charset="utf-8" />

    <link rel="stylesheet" href="/static/pygments/style.css" type="text/css" media="screen" charset="utf-8" />

        <link rel="stylesheet" href="/static/jquery/jquery-ui-1.8.11.custom.css" type="text/css" media="screen" charset="utf-8" />
        
    
    <link rel="alternate" type="application/rss+xml" title="RSS" href="/forums/topic/775/rss" />

        <style type="text/css">
            body {
                height: auto;
            }
        </style>
        <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
        <!--[if lt IE 9]>
        <script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->

        <!-- Le fav and touch icons -->
        <link rel="apple-touch-icon" href="images/apple-touch-icon.png">
        <link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png">
        <link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png">
    </head>

     <body>
        <div class="navbar navbar-fixed-top">
            <div class="navbar-inner">
                <div id="id_internal_nav_bar_container" class="container">
                    <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    </a>
                    <a class="brand" href="/"><img id="id_logo" src="/static/anywhere/images/logo-234x35.png" height="35" title="PythonAnywhere logo" alt="PythonAnywhere logo" /></a>
                    <div class="nav-collapse">
                        <ul id="id_header_links" class="nav">
                            <li><a id="id_feedback_link" class='feedback_link' href="">Send feedback</a></li>
                            <li><a id="id_forums_link" href="/forums/">Forums</a></li>
                            <li><a href="/wiki/" id="id_help_link">Help</a></li>
                            <li><a href="http://blog.pythonanywhere.com/" id="id_blog_link">Blog</a></li>
                            
                            
                                <li><a style="font-weight: bold;" href="/pricing/" id="id_pricing_link">Pricing & signup</a></li>
                                <li><a href="/login/?next=/forums/topic/775/" id="id_login_link">Log in</a></li>
                            
                        </ul>
                    </div>
                </div>
            </div>
        </div>

        <div class="top-container" id="id_dummy"></div>

        

        
    
    <div class="container">
        <div class="row">
            <div class="span8 offset3">
                <h1>PythonAnywhere Forums</h1>
            </div>
        </div>



    <div class="row">
        <div class="span8 offset3">
            <p>
                <a href="/forums/start_topic/" id="id_start_new_topic">Start a new topic</a> |
                <a href="/forums/">Back to all topics</a> |
                <a href="/forums/topic/775/rss">This topic's RSS</a>
            </p>
        </div>
    </div>
    <div class="row">
        <div class="span8 offset3 topic">
            <h2>PIL jpeg decoder not available when starting script from bash console</h2>
        </div>
    </div>

    
        <div class="row">
            <div id="id_post_5494" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5494_content_text" class="span8">
                        <p>I have a Flask Web App that loads and manipulates JPEG images. To improve performance I would like to preprocess some of these images using a cron job. While the code works fairly well in a Flask Context, I don't succeed in running the same code from a bash console or through cron. The stack trace I got looks like this:</p>
<div class="codehilite"><pre><span class="n">Traceback</span> <span class="p">(</span><span class="n">most</span> <span class="n">recent</span> <span class="n">call</span> <span class="n">last</span><span class="p">):</span>
  <span class="n">File</span> <span class="s">&quot;teampicscron.py&quot;</span><span class="p">,</span> <span class="n">line</span> <span class="mi">61</span><span class="p">,</span> <span class="ow">in</span> <span class="o">&lt;</span><span class="n">module</span><span class="o">&gt;</span>
    <span class="n">img</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">crop</span><span class="p">((</span><span class="nb">int</span><span class="p">(</span><span class="n">x_offset</span><span class="p">),</span> <span class="nb">int</span><span class="p">(</span><span class="n">y_offset</span><span class="p">),</span> <span class="nb">int</span><span class="p">(</span><span class="n">x_offset</span><span class="p">)</span><span class="o">+</span><span class="nb">int</span><span class="p">(</span><span class="n">crop_width</span><span class="p">),</span> <span class="nb">int</span><span class="p">(</span><span class="n">y_offset</span><span class="p">)</span><span class="o">+</span><span class="nb">int</span><span class="p">(</span><span class="n">crop_height</span><span class="p">)))</span>
  <span class="n">File</span> <span class="s">&quot;/usr/local/lib/python2.7/dist-packages/PIL/Image.py&quot;</span><span class="p">,</span> <span class="n">line</span> <span class="mi">763</span><span class="p">,</span> <span class="ow">in</span> <span class="n">crop</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>
  <span class="n">File</span> <span class="s">&quot;/usr/local/lib/python2.7/dist-packages/PIL/ImageFile.py&quot;</span><span class="p">,</span> <span class="n">line</span> <span class="mi">189</span><span class="p">,</span> <span class="ow">in</span> <span class="n">load</span>
    <span class="n">d</span> <span class="o">=</span> <span class="n">Image</span><span class="o">.</span><span class="n">_getdecoder</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mode</span><span class="p">,</span> <span class="n">d</span><span class="p">,</span> <span class="n">a</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">decoderconfig</span><span class="p">)</span>
  <span class="n">File</span> <span class="s">&quot;/usr/local/lib/python2.7/dist-packages/PIL/Image.py&quot;</span><span class="p">,</span> <span class="n">line</span> <span class="mi">385</span><span class="p">,</span> <span class="ow">in</span> <span class="n">_getdecoder</span>
    <span class="k">raise</span> <span class="ne">IOError</span><span class="p">(</span><span class="s">&quot;decoder </span><span class="si">%s</span><span class="s"> not available&quot;</span> <span class="o">%</span> <span class="n">decoder_name</span><span class="p">)</span>
<span class="ne">IOError</span><span class="p">:</span> <span class="n">decoder</span> <span class="n">jpeg</span> <span class="ow">not</span> <span class="n">available</span>
</pre></div>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5494_creator_details">
                            
                                
                                    <img src="/static/anywhere/images/star.gif" alt="Beloved premium user" title="Beloved premium user"/>
                                
                            
                            npohle
                            |
                            10
                            posts
                            |
                            
                        </span>
                        <span id="id_post_5494_created_date">
                            July 21, 2013, 10:47 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/775/#id_post_5494">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5500" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5500_content_text" class="span8">
                        <p>That is <em>weird</em>.  The web servers and console servers have exactly the same libraries and packages installed... Can you share a bit more example code, so we can try and repro?</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5500_creator_details">
                            
                                <img src="/static/anywhere/images/staff.png" alt="Staff" title="Staff"/>
                            
                            harry
                            |
                            376
                            posts
                            |
                            
                                PythonAnywhere staff
                                |
                            
                        </span>
                        <span id="id_post_5500_created_date">
                            July 22, 2013, 11:18 a.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/775/#id_post_5500">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5507" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5507_content_text" class="span8">
                        <p>Is either your web app or scheduled job running in a virtualenv? If so, did you create it some time ago? Some virtualenvs were broken by the Ubuntu upgrade, but that wasn't particularly recent. Even ignoring that issue, it would be useful to know if either (or both) of your tests is within a virtualenv.</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5507_creator_details">
                            
                                
                                    <img src="/static/anywhere/images/star.gif" alt="Beloved premium user" title="Beloved premium user"/>
                                
                            
                            Cartroo
                            |
                            638
                            posts
                            |
                            
                        </span>
                        <span id="id_post_5507_created_date">
                            July 22, 2013, 1:17 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/775/#id_post_5507">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5509" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5509_content_text" class="span8">
                        <p>Here's the Flask code:</p>
<div class="codehilite"><pre><span class="kn">from</span> <span class="nn">flask</span> <span class="kn">import</span> <span class="n">Flask</span><span class="p">,</span> <span class="n">request</span><span class="p">,</span> <span class="n">json</span><span class="p">,</span> <span class="n">Response</span><span class="p">,</span> <span class="n">send_file</span>
<span class="kn">from</span> <span class="nn">functools</span> <span class="kn">import</span> <span class="n">wraps</span>
<span class="kn">import</span> <span class="nn">requests</span>
<span class="kn">import</span> <span class="nn">urllib</span>
<span class="kn">from</span> <span class="nn">PIL</span> <span class="kn">import</span> <span class="n">Image</span>
<span class="kn">import</span> <span class="nn">ImageDraw</span><span class="o">,</span> <span class="nn">ImageFont</span>
<span class="kn">import</span> <span class="nn">StringIO</span>
<span class="kn">from</span> <span class="nn">os</span> <span class="kn">import</span> <span class="n">listdir</span>
<span class="kn">from</span> <span class="nn">os.path</span> <span class="kn">import</span> <span class="n">isfile</span><span class="p">,</span> <span class="n">join</span>
<span class="kn">import</span> <span class="nn">random</span>
<span class="kn">import</span> <span class="nn">sys</span><span class="o">,</span> <span class="nn">string</span><span class="o">,</span> <span class="nn">xmlrpclib</span><span class="o">,</span> <span class="nn">re</span>

<span class="nd">@app.route</span><span class="p">(</span><span class="s">&#39;/images&#39;</span><span class="p">,</span> <span class="n">methods</span><span class="o">=</span><span class="p">[</span><span class="s">&#39;GET&#39;</span><span class="p">])</span>
<span class="k">def</span> <span class="nf">images</span><span class="p">():</span>

   <span class="n">server</span> <span class="o">=</span> <span class="n">xmlrpclib</span><span class="o">.</span><span class="n">ServerProxy</span><span class="p">(</span><span class="s">&#39;https://xxxxx.example.com/rpc/xmlrpc&#39;</span><span class="p">)</span>
   <span class="n">token</span> <span class="o">=</span> <span class="n">server</span><span class="o">.</span><span class="n">confluence1</span><span class="o">.</span><span class="n">login</span><span class="p">(</span><span class="s">&#39;xxxxx&#39;</span><span class="p">,</span> <span class="s">&#39;xxxxxxxxxxx&#39;</span><span class="p">)</span>
   <span class="n">page</span> <span class="o">=</span> <span class="n">server</span><span class="o">.</span><span class="n">confluence2</span><span class="o">.</span><span class="n">getPage</span><span class="p">(</span><span class="n">token</span><span class="p">,</span> <span class="s">&#39;xxxxxx&#39;</span><span class="p">,</span> <span class="s">&#39;Team Pics&#39;</span><span class="p">)</span>
   <span class="n">attachments</span> <span class="o">=</span> <span class="n">server</span><span class="o">.</span><span class="n">confluence1</span><span class="o">.</span><span class="n">getAttachments</span><span class="p">(</span><span class="n">token</span><span class="p">,</span> <span class="n">page</span><span class="p">[</span><span class="s">&#39;id&#39;</span><span class="p">])</span>
   <span class="n">attachment</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="n">choice</span> <span class="p">(</span><span class="n">attachments</span><span class="p">)</span>
   <span class="n">data</span> <span class="o">=</span> <span class="n">server</span><span class="o">.</span><span class="n">confluence1</span><span class="o">.</span><span class="n">getAttachmentData</span><span class="p">(</span><span class="n">token</span><span class="p">,</span> <span class="n">page</span><span class="p">[</span><span class="s">&#39;id&#39;</span><span class="p">],</span> <span class="n">attachment</span><span class="p">[</span><span class="s">&#39;fileName&#39;</span><span class="p">],</span> <span class="s">&#39;0&#39;</span><span class="p">)</span>
   <span class="nb">file</span> <span class="o">=</span> <span class="n">StringIO</span><span class="o">.</span><span class="n">StringIO</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
   <span class="n">img</span> <span class="o">=</span> <span class="n">Image</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="nb">file</span><span class="p">)</span>

   <span class="n">teampic</span> <span class="o">=</span> <span class="n">attachment</span><span class="p">[</span><span class="s">&#39;fileName&#39;</span><span class="p">]</span>
   <span class="n">src_width</span><span class="p">,</span> <span class="n">src_height</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">size</span>
   <span class="n">src_ratio</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">src_width</span><span class="p">)</span> <span class="o">/</span> <span class="nb">float</span><span class="p">(</span><span class="n">src_height</span><span class="p">)</span>
   <span class="n">dst_width</span> <span class="o">=</span> <span class="mi">170</span>
   <span class="n">dst_height</span> <span class="o">=</span> <span class="mi">220</span>
   <span class="n">dst_ratio</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">dst_width</span><span class="p">)</span> <span class="o">/</span> <span class="nb">float</span><span class="p">(</span><span class="n">dst_height</span><span class="p">)</span>

   <span class="k">if</span> <span class="n">dst_ratio</span> <span class="o">&lt;</span> <span class="n">src_ratio</span><span class="p">:</span>
       <span class="n">crop_height</span> <span class="o">=</span> <span class="n">src_height</span>
       <span class="n">crop_width</span> <span class="o">=</span> <span class="n">crop_height</span> <span class="o">*</span> <span class="n">dst_ratio</span>
       <span class="n">x_offset</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">src_width</span> <span class="o">-</span> <span class="n">crop_width</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</span>
       <span class="n">y_offset</span> <span class="o">=</span> <span class="mi">0</span>
   <span class="k">else</span><span class="p">:</span>
       <span class="n">crop_width</span> <span class="o">=</span> <span class="n">src_width</span>
       <span class="n">crop_height</span> <span class="o">=</span> <span class="n">crop_width</span> <span class="o">/</span> <span class="n">dst_ratio</span>
       <span class="n">x_offset</span> <span class="o">=</span> <span class="mi">0</span>
       <span class="n">y_offset</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">src_height</span> <span class="o">-</span> <span class="n">crop_height</span><span class="p">)</span> <span class="o">/</span> <span class="mi">3</span>
   <span class="n">img</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">crop</span><span class="p">((</span><span class="nb">int</span><span class="p">(</span><span class="n">x_offset</span><span class="p">),</span> <span class="nb">int</span><span class="p">(</span><span class="n">y_offset</span><span class="p">),</span> <span class="nb">int</span><span class="p">(</span><span class="n">x_offset</span><span class="p">)</span><span class="o">+</span><span class="nb">int</span><span class="p">(</span><span class="n">crop_width</span><span class="p">),</span> <span class="nb">int</span><span class="p">(</span><span class="n">y_offset</span><span class="p">)</span><span class="o">+</span><span class="nb">int</span><span class="p">(</span><span class="n">crop_height</span><span class="p">)))</span>
   <span class="n">img</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">resize</span><span class="p">((</span><span class="nb">int</span><span class="p">(</span><span class="n">dst_width</span><span class="p">),</span> <span class="nb">int</span><span class="p">(</span><span class="n">dst_height</span><span class="p">)),</span> <span class="n">Image</span><span class="o">.</span><span class="n">ANTIALIAS</span><span class="p">)</span>
   <span class="n">img</span> <span class="o">=</span> <span class="n">grayscale_image</span><span class="p">(</span><span class="n">img</span><span class="p">)</span> <span class="c"># convert image to black and white</span>
</pre></div>


<p>Here's the code I try to run through bash:</p>
<div class="codehilite"><pre><span class="kn">from</span> <span class="nn">functools</span> <span class="kn">import</span> <span class="n">wraps</span>
<span class="kn">import</span> <span class="nn">requests</span>
<span class="kn">import</span> <span class="nn">urllib</span>
<span class="kn">from</span> <span class="nn">PIL</span> <span class="kn">import</span> <span class="n">Image</span>
<span class="kn">from</span> <span class="nn">PIL</span> <span class="kn">import</span> <span class="n">ImageDraw</span><span class="p">,</span> <span class="n">ImageFont</span>
<span class="kn">import</span> <span class="nn">StringIO</span>
<span class="kn">from</span> <span class="nn">os</span> <span class="kn">import</span> <span class="n">listdir</span>
<span class="kn">from</span> <span class="nn">os.path</span> <span class="kn">import</span> <span class="n">isfile</span><span class="p">,</span> <span class="n">join</span>
<span class="kn">import</span> <span class="nn">random</span>
<span class="kn">import</span> <span class="nn">sys</span><span class="o">,</span> <span class="nn">string</span><span class="o">,</span> <span class="nn">xmlrpclib</span><span class="o">,</span> <span class="nn">re</span>

<span class="n">server</span> <span class="o">=</span> <span class="n">xmlrpclib</span><span class="o">.</span><span class="n">ServerProxy</span><span class="p">(</span><span class="s">&#39;https://xxxxxxxx.xxxx.com/rpc/xmlrpc&#39;</span><span class="p">)</span>
<span class="n">token</span> <span class="o">=</span> <span class="n">server</span><span class="o">.</span><span class="n">confluence1</span><span class="o">.</span><span class="n">login</span><span class="p">(</span><span class="s">&#39;xxxxx&#39;</span><span class="p">,</span> <span class="s">&#39;xxxxxxxxx&#39;</span><span class="p">)</span>
<span class="n">page</span> <span class="o">=</span> <span class="n">server</span><span class="o">.</span><span class="n">confluence2</span><span class="o">.</span><span class="n">getPage</span><span class="p">(</span><span class="n">token</span><span class="p">,</span> <span class="s">&#39;xxxxx&#39;</span><span class="p">,</span> <span class="s">&#39;Team Pics&#39;</span><span class="p">)</span>
<span class="n">attachments</span> <span class="o">=</span> <span class="n">server</span><span class="o">.</span><span class="n">confluence1</span><span class="o">.</span><span class="n">getAttachments</span><span class="p">(</span><span class="n">token</span><span class="p">,</span> <span class="n">page</span><span class="p">[</span><span class="s">&#39;id&#39;</span><span class="p">])</span>

<span class="k">for</span> <span class="n">attachment</span> <span class="ow">in</span> <span class="n">attachments</span><span class="p">:</span>
   <span class="k">print</span> <span class="s">&quot;load &quot;</span><span class="o">+</span> <span class="n">attachment</span><span class="p">[</span><span class="s">&#39;fileName&#39;</span><span class="p">]</span>
   <span class="n">data</span> <span class="o">=</span> <span class="n">server</span><span class="o">.</span><span class="n">confluence1</span><span class="o">.</span><span class="n">getAttachmentData</span><span class="p">(</span><span class="n">token</span><span class="p">,</span> <span class="n">page</span><span class="p">[</span><span class="s">&#39;id&#39;</span><span class="p">],</span> <span class="n">attachment</span><span class="p">[</span><span class="s">&#39;fileName&#39;</span><span class="p">],</span> <span class="s">&#39;0&#39;</span><span class="p">)</span>
   <span class="nb">file</span> <span class="o">=</span> <span class="n">StringIO</span><span class="o">.</span><span class="n">StringIO</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
   <span class="n">img</span> <span class="o">=</span> <span class="n">Image</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="nb">file</span><span class="p">)</span>

   <span class="n">teampic</span> <span class="o">=</span> <span class="n">attachment</span><span class="p">[</span><span class="s">&#39;fileName&#39;</span><span class="p">]</span>

   <span class="k">print</span> <span class="s">&quot;proc &quot;</span><span class="o">+</span> <span class="n">attachment</span><span class="p">[</span><span class="s">&#39;fileName&#39;</span><span class="p">]</span>
   <span class="n">src_width</span><span class="p">,</span> <span class="n">src_height</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">size</span>
   <span class="n">src_ratio</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">src_width</span><span class="p">)</span> <span class="o">/</span> <span class="nb">float</span><span class="p">(</span><span class="n">src_height</span><span class="p">)</span>
   <span class="n">dst_width</span> <span class="o">=</span> <span class="mi">170</span>
   <span class="n">dst_height</span> <span class="o">=</span> <span class="mi">220</span>
   <span class="n">dst_ratio</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">dst_width</span><span class="p">)</span> <span class="o">/</span> <span class="nb">float</span><span class="p">(</span><span class="n">dst_height</span><span class="p">)</span>

   <span class="k">if</span> <span class="n">dst_ratio</span> <span class="o">&lt;</span> <span class="n">src_ratio</span><span class="p">:</span>
       <span class="n">crop_height</span> <span class="o">=</span> <span class="n">src_height</span>
       <span class="n">crop_width</span> <span class="o">=</span> <span class="n">crop_height</span> <span class="o">*</span> <span class="n">dst_ratio</span>
       <span class="n">x_offset</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">src_width</span> <span class="o">-</span> <span class="n">crop_width</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</span>
       <span class="n">y_offset</span> <span class="o">=</span> <span class="mi">0</span>
   <span class="k">else</span><span class="p">:</span>
       <span class="n">crop_width</span> <span class="o">=</span> <span class="n">src_width</span>
       <span class="n">crop_height</span> <span class="o">=</span> <span class="n">crop_width</span> <span class="o">/</span> <span class="n">dst_ratio</span>
       <span class="n">x_offset</span> <span class="o">=</span> <span class="mi">0</span>
       <span class="n">y_offset</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">src_height</span> <span class="o">-</span> <span class="n">crop_height</span><span class="p">)</span> <span class="o">/</span> <span class="mi">3</span>
   <span class="n">img</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">crop</span><span class="p">((</span><span class="nb">int</span><span class="p">(</span><span class="n">x_offset</span><span class="p">),</span> <span class="nb">int</span><span class="p">(</span><span class="n">y_offset</span><span class="p">),</span> <span class="nb">int</span><span class="p">(</span><span class="n">x_offset</span><span class="p">)</span><span class="o">+</span><span class="nb">int</span><span class="p">(</span><span class="n">crop_width</span><span class="p">),</span> <span class="nb">int</span><span class="p">(</span><span class="n">y_offset</span><span class="p">)</span><span class="o">+</span><span class="nb">int</span><span class="p">(</span><span class="n">crop_height</span><span class="p">)))</span>   <span class="c">#HERE IT BREAKS</span>
   <span class="n">img</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">resize</span><span class="p">((</span><span class="nb">int</span><span class="p">(</span><span class="n">dst_width</span><span class="p">),</span> <span class="nb">int</span><span class="p">(</span><span class="n">dst_height</span><span class="p">)),</span> <span class="n">Image</span><span class="o">.</span><span class="n">ANTIALIAS</span><span class="p">)</span>
   <span class="n">img</span> <span class="o">=</span> <span class="n">grayscale_image</span><span class="p">(</span><span class="n">img</span><span class="p">)</span> <span class="c"># convert image to black and white</span>
</pre></div>


<p>I'm not aware running in a virtualenv. To be honest, I'm not even really sure what that is...</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5509_creator_details">
                            
                                
                                    <img src="/static/anywhere/images/star.gif" alt="Beloved premium user" title="Beloved premium user"/>
                                
                            
                            npohle
                            |
                            10
                            posts
                            |
                            
                        </span>
                        <span id="id_post_5509_created_date">
                            July 22, 2013, 2:01 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/775/#id_post_5509">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5513" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5513_content_text" class="span8">
                        <p>OK, I can't use that code to try and reproduce the error, because I don't have access to that XMLRPC thing.   Can you simplify it down and try and create a "minimal repro"?</p>
<p>Ideally, just 2 or 3 lines of code that try and load a local image file and call the problematic img.crop() function?</p>
<p>If you're feeling really curious, you could do the same inside your Flask app, create a new view+url, just do try and repro the problem, with those same 3 lines of code...</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5513_creator_details">
                            
                                <img src="/static/anywhere/images/staff.png" alt="Staff" title="Staff"/>
                            
                            harry
                            |
                            376
                            posts
                            |
                            
                                PythonAnywhere staff
                                |
                            
                        </span>
                        <span id="id_post_5513_created_date">
                            July 22, 2013, 2:51 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/775/#id_post_5513">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5517" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5517_content_text" class="span8">
                        <p>Here's a simplified version that breaks as well if invoked through bash :</p>
<div class="codehilite"><pre><span class="kn">import</span> <span class="nn">urllib</span>
<span class="kn">from</span> <span class="nn">PIL</span> <span class="kn">import</span> <span class="n">Image</span>
<span class="kn">import</span> <span class="nn">StringIO</span>

<span class="nb">file</span> <span class="o">=</span> <span class="n">StringIO</span><span class="o">.</span><span class="n">StringIO</span><span class="p">(</span><span class="n">urllib</span><span class="o">.</span><span class="n">urlopen</span><span class="p">(</span><span class="s">&#39;http://www3.nd.edu/~networks/HumanDynamics_20Oct05/images/Einstein_1_JPEG.jpg&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">read</span><span class="p">())</span>
<span class="n">img</span> <span class="o">=</span> <span class="n">Image</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="nb">file</span><span class="p">)</span>
<span class="n">img</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">crop</span><span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">400</span><span class="p">,</span> <span class="mi">600</span><span class="p">))</span>   <span class="c">#HERE IT BREAKS</span>
</pre></div>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5517_creator_details">
                            
                                
                                    <img src="/static/anywhere/images/star.gif" alt="Beloved premium user" title="Beloved premium user"/>
                                
                            
                            npohle
                            |
                            10
                            posts
                            |
                            
                        </span>
                        <span id="id_post_5517_created_date">
                            July 22, 2013, 4:06 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/775/#id_post_5517">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5519" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5519_content_text" class="span8">
                        <p>I get this error, even before the "img.crop":</p>
<div class="codehilite"><pre><span class="mi">16</span><span class="p">:</span><span class="mi">55</span> <span class="o">~</span> <span class="err">$</span> <span class="n">python</span> <span class="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">piltestting</span><span class="o">.</span><span class="n">py</span>
<span class="n">Traceback</span> <span class="p">(</span><span class="n">most</span> <span class="n">recent</span> <span class="n">call</span> <span class="n">last</span><span class="p">):</span>
  <span class="n">File</span> <span class="s">&quot;/tmp/piltestting.py&quot;</span><span class="p">,</span> <span class="n">line</span> <span class="mi">6</span><span class="p">,</span> <span class="ow">in</span> <span class="o">&lt;</span><span class="n">module</span><span class="o">&gt;</span>
    <span class="n">img</span> <span class="o">=</span> <span class="n">Image</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="nb">file</span><span class="p">)</span>
  <span class="n">File</span> <span class="s">&quot;/usr/local/lib/python2.7/dist-packages/PIL/Image.py&quot;</span><span class="p">,</span> <span class="n">line</span> <span class="mi">1980</span><span class="p">,</span> <span class="ow">in</span> <span class="nb">open</span>
    <span class="k">raise</span> <span class="ne">IOError</span><span class="p">(</span><span class="s">&quot;cannot identify image file&quot;</span><span class="p">)</span>
<span class="ne">IOError</span><span class="p">:</span> <span class="n">cannot</span> <span class="n">identify</span> <span class="n">image</span> <span class="nb">file</span>
</pre></div>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5519_creator_details">
                            
                                <img src="/static/anywhere/images/staff.png" alt="Staff" title="Staff"/>
                            
                            harry
                            |
                            376
                            posts
                            |
                            
                                PythonAnywhere staff
                                |
                            
                        </span>
                        <span id="id_post_5519_created_date">
                            July 22, 2013, 4:58 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/775/#id_post_5519">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5520" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5520_content_text" class="span8">
                        <p>Same on a local windows pc...  Is there something wrong with the source image file?</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5520_creator_details">
                            
                                <img src="/static/anywhere/images/staff.png" alt="Staff" title="Staff"/>
                            
                            harry
                            |
                            376
                            posts
                            |
                            
                                PythonAnywhere staff
                                |
                            
                        </span>
                        <span id="id_post_5520_created_date">
                            July 22, 2013, 5:01 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/775/#id_post_5520">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5522" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5522_content_text" class="span8">
                        <p>I'm puzzled. An hour ago I got a different error message than I get now:</p>
<div class="codehilite"><pre>16:04 ~/crons <span class="nv">$ </span>python teampicscrontest.py 
Traceback <span class="o">(</span>most recent call last<span class="o">)</span>:
  File <span class="s2">&quot;teampicscrontest.py&quot;</span>, line 8, in &lt;module&gt;
    <span class="nv">img</span> <span class="o">=</span> img.crop<span class="o">((</span>0, 0, 400, 600<span class="o">))</span>   <span class="c">#HERE IT BREAKS</span>
  File <span class="s2">&quot;/usr/local/lib/python2.7/dist-packages/PIL/Image.py&quot;</span>, line 763, in crop
    self.load<span class="o">()</span>
  File <span class="s2">&quot;/usr/local/lib/python2.7/dist-packages/PIL/ImageFile.py&quot;</span>, line 189, in load
    <span class="nv">d</span> <span class="o">=</span> Image._getdecoder<span class="o">(</span>self.mode, d, a, self.decoderconfig<span class="o">)</span>
  File <span class="s2">&quot;/usr/local/lib/python2.7/dist-packages/PIL/Image.py&quot;</span>, line 385, in _getdecoder
    raise IOError<span class="o">(</span><span class="s2">&quot;decoder %s not available&quot;</span> % decoder_name<span class="o">)</span>
IOError: decoder jpeg not available
16:05 ~/crons <span class="nv">$ </span>
17:19 ~/crons <span class="nv">$ </span>python teampicscrontest.py 
Traceback <span class="o">(</span>most recent call last<span class="o">)</span>:
  File <span class="s2">&quot;teampicscrontest.py&quot;</span>, line 6, in &lt;module&gt;
    <span class="nv">img</span> <span class="o">=</span> Image.open<span class="o">(</span>file<span class="o">)</span>
  File <span class="s2">&quot;/usr/local/lib/python2.7/dist-packages/PIL/Image.py&quot;</span>, line 1980, in open
    raise IOError<span class="o">(</span><span class="s2">&quot;cannot identify image file&quot;</span><span class="o">)</span>
IOError: cannot identify image file
17:19 ~/crons
</pre></div>


<p>Did you change anything? I have to re-check how this example behaves in a Flask environment. It's still kind of strange indeed. The image file looks o.k. as far as I can tell but we can check with other images of course.</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5522_creator_details">
                            
                                
                                    <img src="/static/anywhere/images/star.gif" alt="Beloved premium user" title="Beloved premium user"/>
                                
                            
                            npohle
                            |
                            10
                            posts
                            |
                            
                        </span>
                        <span id="id_post_5522_created_date">
                            July 22, 2013, 5:25 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/775/#id_post_5522">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5527" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5527_content_text" class="span8">
                        <p>Checked the source in a Flask web app again:</p>
<div class="codehilite"><pre><span class="kn">from</span> <span class="nn">flask</span> <span class="kn">import</span> <span class="n">Flask</span><span class="p">,</span> <span class="n">request</span><span class="p">,</span> <span class="n">json</span><span class="p">,</span> <span class="n">Response</span><span class="p">,</span> <span class="n">send_file</span>
<span class="kn">from</span> <span class="nn">functools</span> <span class="kn">import</span> <span class="n">wraps</span>
<span class="kn">import</span> <span class="nn">requests</span>
<span class="kn">import</span> <span class="nn">urllib</span>
<span class="kn">from</span> <span class="nn">PIL</span> <span class="kn">import</span> <span class="n">Image</span>
<span class="kn">import</span> <span class="nn">ImageDraw</span><span class="o">,</span> <span class="nn">ImageFont</span>
<span class="kn">import</span> <span class="nn">StringIO</span>
<span class="kn">from</span> <span class="nn">os</span> <span class="kn">import</span> <span class="n">listdir</span>
<span class="kn">from</span> <span class="nn">os.path</span> <span class="kn">import</span> <span class="n">isfile</span><span class="p">,</span> <span class="n">join</span>
<span class="kn">import</span> <span class="nn">random</span>
<span class="kn">import</span> <span class="nn">sys</span><span class="o">,</span> <span class="nn">string</span><span class="o">,</span> <span class="nn">xmlrpclib</span><span class="o">,</span> <span class="nn">re</span>

<span class="n">app</span> <span class="o">=</span> <span class="n">Flask</span><span class="p">(</span><span class="n">__name__</span><span class="p">)</span>

<span class="nd">@app.route</span><span class="p">(</span><span class="s">&#39;/test&#39;</span><span class="p">,</span> <span class="n">methods</span><span class="o">=</span><span class="p">[</span><span class="s">&#39;GET&#39;</span><span class="p">])</span>
<span class="k">def</span> <span class="nf">test</span><span class="p">():</span>

    <span class="nb">file</span> <span class="o">=</span> <span class="n">StringIO</span><span class="o">.</span><span class="n">StringIO</span><span class="p">(</span><span class="n">urllib</span><span class="o">.</span><span class="n">urlopen</span><span class="p">(</span><span class="s">&#39;http://www3.nd.edu/~networks/HumanDynamics_20Oct05/images/Einstein_1_JPEG.jpg&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">read</span><span class="p">())</span>
    <span class="n">img</span> <span class="o">=</span> <span class="n">Image</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="nb">file</span><span class="p">)</span>
    <span class="n">img</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">crop</span><span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">400</span><span class="p">,</span> <span class="mi">600</span><span class="p">))</span>

    <span class="k">return</span> <span class="s">&quot;OK&quot;</span>
</pre></div>


<p>It seems to work flawlessly: http://npohle.pythonanywhere.com/test</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5527_creator_details">
                            
                                
                                    <img src="/static/anywhere/images/star.gif" alt="Beloved premium user" title="Beloved premium user"/>
                                
                            
                            npohle
                            |
                            10
                            posts
                            |
                            
                        </span>
                        <span id="id_post_5527_created_date">
                            July 22, 2013, 9 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/775/#id_post_5527">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5528" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5528_content_text" class="span8">
                        <p>another check to demonstrate it works in a Flask context: http://npohle.pythonanywhere.com/test2</p>
<div class="codehilite"><pre><span class="kn">from</span> <span class="nn">flask</span> <span class="kn">import</span> <span class="n">Flask</span><span class="p">,</span> <span class="n">request</span><span class="p">,</span> <span class="n">json</span><span class="p">,</span> <span class="n">Response</span><span class="p">,</span> <span class="n">send_file</span>
<span class="kn">from</span> <span class="nn">functools</span> <span class="kn">import</span> <span class="n">wraps</span>
<span class="kn">import</span> <span class="nn">requests</span>
<span class="kn">import</span> <span class="nn">urllib</span>
<span class="kn">from</span> <span class="nn">PIL</span> <span class="kn">import</span> <span class="n">Image</span>
<span class="kn">import</span> <span class="nn">ImageDraw</span><span class="o">,</span> <span class="nn">ImageFont</span>
<span class="kn">import</span> <span class="nn">StringIO</span>
<span class="kn">from</span> <span class="nn">os</span> <span class="kn">import</span> <span class="n">listdir</span>
<span class="kn">from</span> <span class="nn">os.path</span> <span class="kn">import</span> <span class="n">isfile</span><span class="p">,</span> <span class="n">join</span>
<span class="kn">import</span> <span class="nn">random</span>
<span class="kn">import</span> <span class="nn">sys</span><span class="o">,</span> <span class="nn">string</span><span class="o">,</span> <span class="nn">xmlrpclib</span><span class="o">,</span> <span class="nn">re</span>

<span class="k">def</span> <span class="nf">serve_pil_image</span><span class="p">(</span><span class="n">pil_img</span><span class="p">):</span>
    <span class="n">img_io</span> <span class="o">=</span> <span class="n">StringIO</span><span class="o">.</span><span class="n">StringIO</span><span class="p">()</span>
    <span class="c">#pil_img.save(img_io, &#39;JPEG&#39;, quality=100)</span>
    <span class="n">pil_img</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">img_io</span><span class="p">,</span> <span class="s">&#39;PNG&#39;</span><span class="p">,</span> <span class="n">quality</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>
    <span class="n">img_io</span><span class="o">.</span><span class="n">seek</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
    <span class="k">return</span> <span class="n">send_file</span><span class="p">(</span><span class="n">img_io</span><span class="p">,</span> <span class="n">mimetype</span><span class="o">=</span><span class="s">&#39;image/png&#39;</span><span class="p">)</span>

<span class="n">app</span> <span class="o">=</span> <span class="n">Flask</span><span class="p">(</span><span class="n">__name__</span><span class="p">)</span>

<span class="nd">@app.route</span><span class="p">(</span><span class="s">&#39;/test2&#39;</span><span class="p">,</span> <span class="n">methods</span><span class="o">=</span><span class="p">[</span><span class="s">&#39;GET&#39;</span><span class="p">])</span>
<span class="k">def</span> <span class="nf">test2</span><span class="p">():</span>

    <span class="nb">file</span> <span class="o">=</span> <span class="n">StringIO</span><span class="o">.</span><span class="n">StringIO</span><span class="p">(</span><span class="n">urllib</span><span class="o">.</span><span class="n">urlopen</span><span class="p">(</span><span class="s">&#39;http://www3.nd.edu/~networks/HumanDynamics_20Oct05/images/Einstein_1_JPEG.jpg&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">read</span><span class="p">())</span>
    <span class="n">img</span> <span class="o">=</span> <span class="n">Image</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="nb">file</span><span class="p">)</span>
    <span class="n">img</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="n">crop</span><span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">400</span><span class="p">,</span> <span class="mi">600</span><span class="p">))</span>

    <span class="k">return</span> <span class="n">serve_pil_image</span><span class="p">(</span><span class="n">img</span><span class="p">)</span>
</pre></div>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5528_creator_details">
                            
                                
                                    <img src="/static/anywhere/images/star.gif" alt="Beloved premium user" title="Beloved premium user"/>
                                
                            
                            npohle
                            |
                            10
                            posts
                            |
                            
                        </span>
                        <span id="id_post_5528_created_date">
                            July 22, 2013, 9:12 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/775/#id_post_5528">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5531" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5531_content_text" class="span8">
                        <p>I just ran the simplified version above in my PA account and it works fine with no error. Does it work for you too, now?</p>
<p>If not, it appears to be either user-dependent (perhaps we're on different servers?) or perhaps you're running in a virtualenv?</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5531_creator_details">
                            
                                
                                    <img src="/static/anywhere/images/star.gif" alt="Beloved premium user" title="Beloved premium user"/>
                                
                            
                            Cartroo
                            |
                            638
                            posts
                            |
                            
                        </span>
                        <span id="id_post_5531_created_date">
                            July 23, 2013, 8:55 a.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/775/#id_post_5531">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5543" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5543_content_text" class="span8">
                        <p>@Cartroo: Thanks for trying. Have you used the Flask code actually or the did you invoke the code from the shell like demonstrated in my post from July 22, 2013, 4:06 p.m.? Just to clarify: The code works for me when invoked as a Flask App but not if invoked as a stand alone Python script.</p>
<p>I don't think I'm using virtualenv, unless Flask is applying some magic here. An obvious difference is that the Flask Code gets compiled into a pyc file and is then loaded as a Web App by PA. Not sure what happens behind the curtains.</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5543_creator_details">
                            
                                
                                    <img src="/static/anywhere/images/star.gif" alt="Beloved premium user" title="Beloved premium user"/>
                                
                            
                            npohle
                            |
                            10
                            posts
                            |
                            
                        </span>
                        <span id="id_post_5543_created_date">
                            July 23, 2013, 11:56 a.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/775/#id_post_5543">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5550" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5550_content_text" class="span8">
                        <p>Yes, your code from <strong>July 22 2013 4:06pm</strong> works fine for me in a bash prompt. For the avoidance of doubt, here is a transcript:</p>
<div class="codehilite"><pre><span class="mi">16</span><span class="o">:</span><span class="mi">51</span> <span class="o">~/</span><span class="n">t</span> <span class="n">$</span> <span class="n">cat</span> <span class="o">&gt;</span> <span class="n">test</span><span class="o">.</span><span class="na">py</span>
<span class="k">import</span> <span class="nn">urllib</span>
<span class="n">from</span> <span class="n">PIL</span> <span class="k">import</span> <span class="nn">Image</span>
<span class="k">import</span> <span class="nn">StringIO</span>

<span class="n">file</span> <span class="o">=</span> <span class="n">StringIO</span><span class="o">.</span><span class="na">StringIO</span><span class="o">(</span><span class="n">urllib</span><span class="o">.</span><span class="na">urlopen</span><span class="o">(</span><span class="s1">&#39;http://www3.nd.edu/~networks/HumanDynamics_20Oct05/images/Einstein_1_JPEG.jpg&#39;</span><span class="o">).</span><span class="n">read</span><span class="o">())</span>
<span class="n">img</span> <span class="o">=</span> <span class="n">Image</span><span class="o">.</span><span class="na">open</span><span class="o">(</span><span class="n">file</span><span class="o">)</span>
<span class="n">img</span> <span class="o">=</span> <span class="n">img</span><span class="o">.</span><span class="na">crop</span><span class="o">((</span><span class="mi">0</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="mi">400</span><span class="o">,</span> <span class="mi">600</span><span class="o">))</span>   <span class="err">#</span><span class="n">HERE</span> <span class="n">IT</span> <span class="n">BREAKS</span>
<span class="mi">16</span><span class="o">:</span><span class="mi">51</span> <span class="o">~/</span><span class="n">t</span> <span class="n">$</span> 
<span class="mi">16</span><span class="o">:</span><span class="mi">51</span> <span class="o">~/</span><span class="n">t</span> <span class="n">$</span> <span class="n">python</span> <span class="o">./</span><span class="n">test</span><span class="o">.</span><span class="na">py</span>
<span class="mi">16</span><span class="o">:</span><span class="mi">51</span> <span class="o">~/</span><span class="n">t</span> <span class="n">$</span>
</pre></div>


<p>As you can see, there's no output so presumably the code is working correctly.</p>
<p>I don't think that the PA system will be doing any magic which is likely to affect this, and it shouldn't be running anything in a virtualenv unless you've deliberately set it up that way.</p>
<p>So there must be something else about the environment which is causing issues. Just for a sanity check, could you fire up a Python interpreter from the bash prompt and run the following two commands in it and paste the output:</p>
<div class="codehilite"><pre><span class="n">import</span> <span class="n">PIL</span>
<span class="n">print</span> <span class="n">PIL</span><span class="p">.</span><span class="n">__file__</span>
</pre></div>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5550_creator_details">
                            
                                
                                    <img src="/static/anywhere/images/star.gif" alt="Beloved premium user" title="Beloved premium user"/>
                                
                            
                            Cartroo
                            |
                            638
                            posts
                            |
                            
                        </span>
                        <span id="id_post_5550_created_date">
                            July 23, 2013, 4:56 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/775/#id_post_5550">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5554" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5554_content_text" class="span8">
                        <p>interesting. I do agree that this most likely has something to do with the specific account / environment then. Here's the output from the 'sanity check':</p>
<div class="codehilite"><pre>18:43 ~/crons <span class="nv">$ </span>python                                                                                                                                                                              
Python 2.7.4 <span class="o">(</span>default, Apr 19 2013, 18:28:01<span class="o">)</span> 
<span class="o">[</span>GCC 4.7.3<span class="o">]</span> on linux2
Type <span class="s2">&quot;help&quot;</span>, <span class="s2">&quot;copyright&quot;</span>, <span class="s2">&quot;credits&quot;</span> or <span class="s2">&quot;license&quot;</span> <span class="k">for </span>more information.
&gt;&gt;&gt; import PIL
&gt;&gt;&gt; PIL.__file__
<span class="s1">&#39;/usr/local/lib/python2.7/dist-packages/PIL/__init__.py&#39;</span>
&gt;&gt;&gt; <span class="nb">exit</span><span class="o">()</span>
18:44 ~/crons <span class="err">$</span>
</pre></div>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5554_creator_details">
                            
                                
                                    <img src="/static/anywhere/images/star.gif" alt="Beloved premium user" title="Beloved premium user"/>
                                
                            
                            npohle
                            |
                            10
                            posts
                            |
                            
                        </span>
                        <span id="id_post_5554_created_date">
                            July 23, 2013, 6:46 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/775/#id_post_5554">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5560" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5560_content_text" class="span8">
                        <p>Hm, so you're importing the same version as me, then. Can you please check if the following files are available on your installation - they should both be there:</p>
<div class="codehilite"><pre><span class="o">/</span><span class="n">usr</span><span class="o">/</span><span class="n">local</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">python2</span><span class="mf">.7</span><span class="o">/</span><span class="n">dist</span><span class="o">-</span><span class="n">packages</span><span class="o">/</span><span class="n">PIL</span><span class="o">/</span><span class="n">_imaging</span><span class="p">.</span><span class="n">so</span>
<span class="o">/</span><span class="n">usr</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">x86_64</span><span class="o">-</span><span class="n">linux</span><span class="o">-</span><span class="n">gnu</span><span class="o">/</span><span class="n">libjpeg</span><span class="p">.</span><span class="n">so</span>
</pre></div>


<p>Also, in a Python shell, could you please run these commands and paste the output:</p>
<div class="codehilite"><pre><span class="kn">from</span> <span class="nn">PIL</span> <span class="kn">import</span> <span class="n">Image</span>
<span class="n">Image</span><span class="o">.</span><span class="n">core</span>
<span class="n">Image</span><span class="o">.</span><span class="n">core</span><span class="o">.</span><span class="n">jpeg_decoder</span>
<span class="n">Image</span><span class="o">.</span><span class="n">_getdecoder</span><span class="p">(</span><span class="s">&quot;RGB&quot;</span><span class="p">,</span> <span class="s">&quot;jpeg&quot;</span><span class="p">,</span> <span class="p">(</span><span class="s">&quot;RGB&quot;</span><span class="p">,</span> <span class="bp">None</span><span class="p">))</span>
</pre></div>


<p>For reference, I'd expect the following:</p>
<div class="codehilite"><pre><span class="o">&gt;&gt;&gt;</span> <span class="kn">from</span> <span class="nn">PIL</span> <span class="kn">import</span> <span class="n">Image</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">Image</span><span class="o">.</span><span class="n">core</span>
<span class="o">&lt;</span><span class="n">module</span> <span class="s">&#39;PIL._imaging&#39;</span> <span class="kn">from</span> <span class="s">&#39;/usr/local/lib/python2.7/dist-packages/PIL/_imaging.so&#39;</span><span class="o">&gt;</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">Image</span><span class="o">.</span><span class="n">core</span><span class="o">.</span><span class="n">jpeg_decoder</span>
<span class="o">&lt;</span><span class="n">built</span><span class="o">-</span><span class="ow">in</span> <span class="n">function</span> <span class="n">jpeg_decoder</span><span class="o">&gt;</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">Image</span><span class="o">.</span><span class="n">_getdecoder</span><span class="p">(</span><span class="s">&quot;RGB&quot;</span><span class="p">,</span> <span class="s">&quot;jpeg&quot;</span><span class="p">,</span> <span class="p">(</span><span class="s">&quot;RGB&quot;</span><span class="p">,</span> <span class="bp">None</span><span class="p">))</span>
<span class="o">&lt;</span><span class="n">ImagingDecoder</span> <span class="nb">object</span> <span class="n">at</span> <span class="mh">0x7f6359442110</span><span class="o">&gt;</span>
</pre></div>


<p>If <code>Image.core</code> isn't defined then it points to a failure to import <code>_imaging.so</code>. If <code>Image.core.jpeg_decoder</code> isn't defined then it would appear that somehow your version of PIL was compiled without JPEG support (it appears to be just a compile-time condition). If both of those are defined by the last function still returns an error then something <em>really</em> odd is going on...</p>
<p>Apologies for making you jump through hoops like this, but it's really puzzling that we appear to be in different environments and so we need to try and get to the bottom of how they differ before we can be confident that we can fix the problem.</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5560_creator_details">
                            
                                
                                    <img src="/static/anywhere/images/star.gif" alt="Beloved premium user" title="Beloved premium user"/>
                                
                            
                            Cartroo
                            |
                            638
                            posts
                            |
                            
                        </span>
                        <span id="id_post_5560_created_date">
                            July 24, 2013, 10:38 a.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/775/#id_post_5560">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5587" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5587_content_text" class="span8">
                        <p>This is definitely weird.  Everyone should have the same environment -- in fact, there's nothing in the system that could allow different consoles to differ, unless there are virtualenvs or some other way of having different Python modules installed.</p>
<p>Hmm, perhaps it's the Python path?  @npohle, could you run Python and then</p>
<div class="codehilite"><pre><span class="kn">import</span> <span class="nn">sys</span>
<span class="k">print</span> <span class="n">sys</span><span class="o">.</span><span class="n">path</span>
</pre></div>


<p>...?</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5587_creator_details">
                            
                                <img src="/static/anywhere/images/staff.png" alt="Staff" title="Staff"/>
                            
                            giles
                            |
                            866
                            posts
                            |
                            
                                PythonAnywhere staff
                                |
                            
                        </span>
                        <span id="id_post_5587_created_date">
                            July 24, 2013, 2:55 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/775/#id_post_5587">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5590" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5590_content_text" class="span8">
                        <p>I wondered about <code>sys.path</code> which is why I suggested printing <code>PIL.__file__</code>, but that seemed to be correct. I don't think <code>sys.path</code> would affect the location that PIL would search for <code>libjpeg</code> - my understanding from a brief look at the code is that it's a compile-time option and it uses the standard dynamic library dependency machinery to load it (rather than using <a href="http://man7.org/linux/man-pages/man3/dlopen.3.html"><code>dlopen()</code></a> or similar) so I wouldn't expect any Python settings to have any effect. Since the error doesn't arise loading PIL, but instead whilst searching for the JPEG decoder, it didn't seem like a Python search path issue (unless it's failing to load <code>_imaging.so</code>, but I'd rather expect a different error in that case). I may well be missing something obvious, however!</p>
<p>I suppose it might be also worth double-checking that the <code>LD_LIBRARY_PATH</code> environment variable isn't being set to something weird.</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5590_creator_details">
                            
                                
                                    <img src="/static/anywhere/images/star.gif" alt="Beloved premium user" title="Beloved premium user"/>
                                
                            
                            Cartroo
                            |
                            638
                            posts
                            |
                            
                        </span>
                        <span id="id_post_5590_created_date">
                            July 24, 2013, 3:50 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/775/#id_post_5590">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5596" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5596_content_text" class="span8">
                        <p>Right, good point -- LD_LIBRARY_PATH could be the cause.  Or perhaps there's some other dependency of PIL -- perhaps even a Python one?  So I guess we need both...</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5596_creator_details">
                            
                                <img src="/static/anywhere/images/staff.png" alt="Staff" title="Staff"/>
                            
                            giles
                            |
                            866
                            posts
                            |
                            
                                PythonAnywhere staff
                                |
                            
                        </span>
                        <span id="id_post_5596_created_date">
                            July 24, 2013, 5:11 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/775/#id_post_5596">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5608" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5608_content_text" class="span8">
                        <p>No worries. I'm glad you are following up :-)
My output (see below) looks very much like yours. That's probably a bad thing as it doesn't reveal any additional insights... maybe its easier to ask for a brand new account? I don't have that much code so transferring everything wouldn't be a big deal. </p>
<p>Having said that, it's an interesting problem and if you want me to try some more stuff I'm happy to do so. It's not a particularly urgent issue. I'm using PA only for nice-to-have stuff anyway.</p>
<div class="codehilite"><pre>21:38 ~ <span class="nv">$ </span>ls /usr/local/lib/python2.7/dist-packages/PIL                                                                                                                                             
PIL  PIL-1.1.7-py2.7.egg-info  _imaging.so  _imagingft.so  _imagingmath.so
21:38 ~ <span class="nv">$ </span>ls /usr/lib/x86_64-linux-gnu/libjpeg.so                                                                                                                                                   
/usr/lib/x86_64-linux-gnu/libjpeg.so
21:38 ~ <span class="nv">$ </span>python
Python 2.7.4 <span class="o">(</span>default, Apr 19 2013, 18:28:01<span class="o">)</span> 
<span class="o">[</span>GCC 4.7.3<span class="o">]</span> on linux2
Type <span class="s2">&quot;help&quot;</span>, <span class="s2">&quot;copyright&quot;</span>, <span class="s2">&quot;credits&quot;</span> or <span class="s2">&quot;license&quot;</span> <span class="k">for </span>more information.
&gt;&gt;&gt; from PIL import Image                                                                                                                                                                           
&gt;&gt;&gt; Image.core
&lt;module <span class="s1">&#39;_imaging&#39;</span> from <span class="s1">&#39;/usr/local/lib/python2.7/dist-packages/PIL/_imaging.so&#39;</span>&gt;
&gt;&gt;&gt; Image.core.jpeg_decoder
&lt;built-in <span class="k">function </span>jpeg_decoder&gt;
&gt;&gt;&gt; Image._getdecoder<span class="o">(</span><span class="s2">&quot;RGB&quot;</span>, <span class="s2">&quot;jpeg&quot;</span>, <span class="o">(</span><span class="s2">&quot;RGB&quot;</span>, None<span class="o">))</span>
&lt;ImagingDecoder object at 0x7f18ceb281f0&gt;
&gt;&gt;&gt;
</pre></div>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5608_creator_details">
                            
                                
                                    <img src="/static/anywhere/images/star.gif" alt="Beloved premium user" title="Beloved premium user"/>
                                
                            
                            npohle
                            |
                            10
                            posts
                            |
                            
                        </span>
                        <span id="id_post_5608_created_date">
                            July 24, 2013, 9:52 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/775/#id_post_5608">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5609" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5609_content_text" class="span8">
                        <p>Oh... and by the way: The issue apparently was secretly solved in the meantime. The original test code from July 22 2013 4:06pm  runs flawlessly when invoked through bash now.</p>
<p>Actually I missed your last posts @Cartroo and @giles (didn't update the tab). Looks like you hit the mark with LD_LIBRARY_PATH and somebody fixed it?</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5609_creator_details">
                            
                                
                                    <img src="/static/anywhere/images/star.gif" alt="Beloved premium user" title="Beloved premium user"/>
                                
                            
                            npohle
                            |
                            10
                            posts
                            |
                            
                        </span>
                        <span id="id_post_5609_created_date">
                            July 24, 2013, 10:10 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/775/#id_post_5609">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5619" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5619_content_text" class="span8">
                        <p>Hm, I doubt <code>LD_LIBRARY_PATH</code> would be set system-wide - I was mentioning it in case you'd set it yourself for some reason.</p>
<p>Glad it's now working for you but I've no idea why - perhaps one the PA servers had got into a half-installed state and needed refreshing or something. Perhaps the PA devs can shed some light... Or perhaps we'll never know! As long as it doesn't break again, I guess all's well that ends well.</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5619_creator_details">
                            
                                
                                    <img src="/static/anywhere/images/star.gif" alt="Beloved premium user" title="Beloved premium user"/>
                                
                            
                            Cartroo
                            |
                            638
                            posts
                            |
                            
                        </span>
                        <span id="id_post_5619_created_date">
                            July 25, 2013, 10:36 a.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/775/#id_post_5619">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5627" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5627_content_text" class="span8">
                        <p>@nphole -- thanks for letting us know.  That's all really strange, but I'm glad it's sorted now.  The only explanation I can think of is that there was a bug in our last release, someone on the team here patched it on some but not all of our servers and also on our development systems, and then yesterday's release updated all of the servers with the fixed version.  And that would be a great explanation if anyone here remembered doing anything like that... </p>
<p>Anyway, we'll keep an eye out for anything related to this in the future, and if it happens again then please do tell us.</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5627_creator_details">
                            
                                <img src="/static/anywhere/images/staff.png" alt="Staff" title="Staff"/>
                            
                            giles
                            |
                            866
                            posts
                            |
                            
                                PythonAnywhere staff
                                |
                            
                        </span>
                        <span id="id_post_5627_created_date">
                            July 25, 2013, 11:58 a.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/775/#id_post_5627">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5631" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5631_content_text" class="span8">
                        <p>Whenever I have a problem I can't explain on remote servers, I blame NSA hackers. That's probably why there's always an unmarked van full of men in black suits and sunglasses following me...</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5631_creator_details">
                            
                                
                                    <img src="/static/anywhere/images/star.gif" alt="Beloved premium user" title="Beloved premium user"/>
                                
                            
                            Cartroo
                            |
                            638
                            posts
                            |
                            
                        </span>
                        <span id="id_post_5631_created_date">
                            July 25, 2013, 4:29 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/775/#id_post_5631">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_5633" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_5633_content_text" class="span8">
                        <p>That must be it!</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_5633_creator_details">
                            
                                <img src="/static/anywhere/images/staff.png" alt="Staff" title="Staff"/>
                            
                            giles
                            |
                            866
                            posts
                            |
                            
                                PythonAnywhere staff
                                |
                            
                        </span>
                        <span id="id_post_5633_created_date">
                            July 25, 2013, 5:08 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/775/#id_post_5633">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    

    




        <div id="id_footer" class="container">

            <footer id="id_copyright_div">
                <p>
                    Copyright &copy; 2013 PythonAnywhere LLP
                    &mdash;
                    <a href="/terms/">Terms</a>
                    &mdash;
                    <a href="/privacy/">Privacy</a><br/>
                    "Python" is a registered trademark of the Python Software Foundation.
                </p>
            </footer>

        </div>

        
        

        <div id="id_feedback_dialog" title="Help us improve" style="display:none">
    <div id="id_feedback_dialog_blurb_big" class="dialog_blurb_big">
        It's always a pleasure to hear from you!
    </div>
    <div id="id_feedback_dialog_blurb_small">
        Ask us a question, or tell us what you love or hate about PythonAnywhere.<br/>
        We'll get back to you over email ASAP.
    </div>
    <textarea id="id_feedback_dialog_text" rows="6"></textarea>
    <input id="id_feedback_dialog_email_address" type="text" class="default_prompt"/>
    <div id="id_feedback_dialog_error" class="pa_hidden">
        Sorry, there was an error connecting to the server. <br/>Please try again in a few moments...
    </div>
    <div class="dialog_buttons">
        <img id="id_feedback_dialog_spinner" src="/static/anywhere/images/spinner-small.gif" />
        <button class="btn btn-primary" id="id_feedback_dialog_ok_button">OK</button>
        <button class="btn" id="id_feedback_dialog_cancel_button">Cancel</button>
    </div>
</div>


        <!-- Le javascript
        ================================================== -->
        <!-- Placed at the end of the document so the pages load faster -->
        <script type="text/javascript" src="/static/jquery/jquery-1.7.1.min.js"></script>
        <script type="text/javascript" src="/static/jquery/jquery-ui-1.8.11.custom.min.js"></script>
        <script src="/static/bootstrap/js/bootstrap-transition.js"></script>
        <script src="/static/bootstrap/js/bootstrap-alert.js"></script>
        <script src="/static/bootstrap/js/bootstrap-modal.js"></script>
        <script src="/static/bootstrap/js/bootstrap-dropdown.js"></script>
        <script src="/static/bootstrap/js/bootstrap-scrollspy.js"></script>
        <script src="/static/bootstrap/js/bootstrap-tab.js"></script>
        <script src="/static/bootstrap/js/bootstrap-tooltip.js"></script>
        <script src="/static/bootstrap/js/bootstrap-popover.js"></script>
        <script src="/static/bootstrap/js/bootstrap-button.js"></script>
        <script src="/static/bootstrap/js/bootstrap-collapse.js"></script>
        <script src="/static/bootstrap/js/bootstrap-carousel.js"></script>
        <script src="/static/bootstrap/js/bootstrap-typeahead.js"></script>

        <script type="text/javascript">
            var urls = {};
            var Anywhere = {};
            Anywhere.urls = {};
        </script>
        <script type="text/javascript" src="/static/anywhere/scripts/ajax_utils.js"></script>

        <script type="text/javascript" src="/static/anywhere/scripts/feedback_dialog.js"></script>
        
        <script type="text/javascript">
            $(function() {
                $.extend(
                    urls,
                    {
                        feedback: '/feedback/submit/'
                    }
                );
                
                    Anywhere.FeedbackDialog.Initialise(urls, false);
                
            });
        </script>

        <script type="text/javascript">

            var _gaq = _gaq || [];
            _gaq.push(['_setAccount', 'UA-18014859-6']);
            _gaq.push(['_trackPageview']);

            (function() {
                var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
                ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
                var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
            })();

        </script>

        



    </body>
</html>
